using System;
using UnityEngine;

namespace Main.CropPlant
{

    [Serializable]
    public class CropDetails
    {
        public int seedItemID;

        [Header("不同阶段所需的生长日期")]
        public int[] growDays;

        // 总时长
        public int DayAmount
        {
            get
            {
                int amount = 0;
                foreach (var item in growDays)
                {
                    amount += item;
                }
                return amount;
            }
        }

        [Header("不同阶段的预制体")]
        public GameObject[] growPrefabs;
        [Header("不同阶段的精灵图片")]
        public Sprite[] growSprites;

        [Header("可种植的季节")]
        public Season[] seasons;

        [Space]
        [Header("收割可以使用的工具")]
        public int[] harvestToolIDs;

        [Header("收割工具对应的使用次数")]
        public int[] harvestToolUseTimes;

        [Header("转换后的新物品ID")]
        public int transferItemID;

        [Space]
        [Header("收割的果实信息")]
        public int[] productItemIDs;

        [Header("每种果品对应的数量最小值")]
        public int[] productItemMinAmounts;

        [Header("每种果品对应的数量最大值")]
        public int[] productItemMaxAmounts;

        [Header("掉落范围")]
        public Vector2 spawnRadius;

        [Header("再次生长时间间隔")]
        public int daysToRegrow;

        [Header("总再生次数")]
        public int regrowTimes;

        [Header("选项")]

        ///是否在玩家周围生成
        public bool generateAtPlayPosition;

        // 是否播放动画
        public bool hasAnimation;

        //是否有粒子效果
        public bool hasParticleEffect;

        public ParticleEffectType partialEffectType;
        public Vector3 effectPos;

        public SoundName soundEffect;

        public bool ToolIsValid(int toolId)
        {
            foreach (var id in harvestToolIDs)
            {
                if (id == toolId)
                {
                    return true;
                }
            }
            return false;
        }

        public int GetToolRequireTimes(int toolId)
        {
            for (int i = 0; i < harvestToolIDs.Length; i++)
            {
                if (harvestToolIDs[i] == toolId)
                {
                    return harvestToolUseTimes[i];
                }
            }
            return -1;
        }
    }
}
